﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;

/// <summary>
/// Holds shipping information, including full name, street address, city, state, and 5-digit zip.
/// Ensures that leading and trailing white space is removed from string when assigning a value.
/// Validity of data is NOT checked by this class and left up to the web form validation controls.
/// </summary>
public class ShippingData
{
    private string firstName = "";
    public string FirstName
    {
        get { return firstName; }
        set { firstName = value.Trim(); }
    }

    private string lastName = "";
    public string LastName
    {
        get { return lastName; }
        set { lastName = value.Trim(); }
    }

    public string FullName
    {
        get { return firstName+" "+lastName; }
        set 
        { 
            string[] names = Regex.Split(value.Trim(), @"\s+");
            firstName = names[0];
            lastName = names[1];
        }
    }

    private string street1 = "";
    public string Street1
    {
        get { return street1; }
        set { street1 = value.Trim(); }
    }

    private string street2 = "";
    public string Street2
    {
        get { return street2; }
        set { street2 = value.Trim(); }
    }

    private string city = "";
    public string City
    {
        get { return city; }
        set { city = value.Trim(); }
    }

    private string state = "";
    public string State
    {
        get { return state; }
        set { state = value.Trim(); }
    }

    private string zip = "";
    public string Zip
    {
        get { return zip; }
        set { zip = value.Trim(); }
    }
}